// pages/my/my.js
const app = getApp()
import {navigate} from "../../loginToken/loginToken"
Page({

        /**
         * 页面的初始数据
         */
        data: {
                list: {
                        balance: [
                                {
                                        num: 0.00,
                                        name: "余额"
                                }, {
                                        num: 0.00,
                                        name: "冻结"
                                }, {
                                        num: 0,
                                        name: "积分"
                                }, {
                                        num: 0,
                                        name: "成长值"
                                },
                        ],
                        myOrder: [
                                {
                                        classIcon: 'icon-fukuan1',
                                        name: '代付款'
                                }, {
                                        classIcon: 'icon-daifahuo',
                                        name: '待发货'
                                }, {
                                        classIcon: 'icon-fenqishangchengdaishouhuo',
                                        name: '待收货'
                                }, {
                                        classIcon: 'icon-daipinglun',
                                        name: '待评论'
                                }, {
                                        classIcon: 'icon-shouhou',
                                        name: '售后'
                                },
                        ],
                        function: [
                                {
                                        classIcon: 'icon-daifukuan',
                                        name: '优惠买单'
                                }, {
                                        classIcon: 'icon-zijinmingxi',
                                        name: '资金明细'
                                }, {
                                        classIcon: 'icon-shenqingfapiao-xianxing',
                                        name: '申请发票'
                                }, {
                                        classIcon: 'icon-lishijilu',
                                        name: '开票记录'
                                }, {
                                        classIcon: 'icon-shenqingfapiao-xianxing',
                                        name: '优惠券'
                                }, {
                                        classIcon: 'icon-qiandao',
                                        name: '签到赚积分'
                                },
                        ]
                },
                username: '',//用户名
                avatarimg: '',//用户头像
                userID:'',//用户id
                balanceIndex:-1,//余额index
                OrderIndex:-2,//我的订单Index
                functionIndex:-1,//常用功能index
                _token:'',
        },


        /**
         * 生命周期函数--监听页面加载
         */
        onLoad: function (options) {
                wx.getStorage({//获取本地的id
                        key:'userID',
                        success:res=>{
                                this.setData({
                                        userID:res.data
                                })
                        }
                }),
                wx.getStorage({//获取本地的username
                        key:'username',
                        success:res=>{
                                this.setData({
                                        username:res.data
                                })
                        }
                })
                wx.getStorage({//获取本地的avatarimg
                        key:'avatarimg',
                        success:res=>{
                                this.setData({
                                        avatarimg:res.data
                                })
                        }
                })
                
        },
        // 余额跳转
        skipPages(e){
                this.setData({
                        balanceIndex:e.currentTarget.dataset.index
                })
               
                if(this.data.balanceIndex===0){
                        wx.navigateTo({//余额
                          url: '/pages/Mydeploy/myProperty/myProperty',
                        })
                }else if(this.data.balanceIndex===1){
                        wx.navigateTo({//冻结
                                url: '/pages/Mydeploy/myProperty/myProperty',
                              })
                }else if(this.data.balanceIndex===2){
                        wx.navigateTo({//积分
                                url: '/pages/Mydeploy/myIntegral/myIntegral',
                              })
                }else if(this.data.balanceIndex===3){
                        wx.navigateTo({//成长值
                                url: '/pages/Mydeploy/myGrowPrice/myGrowprice',
                              })
                }
        },
        // 察看订单
        watchOrder(e){
                this.setData({
                        OrderIndex:e.currentTarget.dataset.index
                })
                if(this.data.OrderIndex==-1){
                        wx.navigateTo({//点击我的订单
                                url: '/pages/Mydeploy/myorder/myorder',
                              })
                }else if(this.data.OrderIndex!==-1 && 4){
                        wx.navigateTo({//点击我的订单下面
                                url: `/pages/Mydeploy/myorder/myorder?index=${this.data.OrderIndex+1}`,
                              })
                }else if(this.data.OrderIndex==4){
                        wx.navigateTo({//点击我的订单下面
                                url: `/pages/Mydeploy/myorder/myorder?index=${this.data.OrderIndex+1}`,
                              })
                }
        },

        // 去CPS订单页面
        toCPS(){
                wx.navigateTo({
                        url: '/pages/Mydeploy/myCPS/myCPS',
                      }) 
        },

        // 去回收订单
        toRecycle(){
                wx.navigateTo({
                        url: '/pages/Mydeploy/myRecycle/myRecycle',
                      }) 
        },

        // 常用功能、、
        tofunction(e){
                this.setData({
                        functionIndex:e.currentTarget.dataset.index
                })
                if(this.data.functionIndex==0){
                        wx.navigateTo({//优惠买单
                                url: '/pages/Mydeploy/myDiscounts/myDiscounts',
                              }) 
                }else if(this.data.functionIndex==1){
                        wx.navigateTo({//资金明细
                                url: '/pages/Mydeploy/myProperty/myProperty',
                              }) 
                }else if(this.data.functionIndex==2){
                        wx.navigateTo({//申请发票
                                url: '/pages/Mydeploy/myAppl_invoicey/myAppl_invoicey',
                              }) 
                }else if(this.data.functionIndex==3){
                        wx.navigateTo({//开票记录
                                url: '/pages/Mydeploy/myOpen_ticket/myOpen_ticket',
                              }) 
                }else if(this.data.functionIndex==4){
                        wx.switchTab ({//优惠券
                                url: '/pages/coupon/coupon',
                              }) 
                }else if(this.data.functionIndex==5){
                        wx.navigateTo({//签到
                                url: '/pages/Mydeploy/mySign/mySign',
                              }) 
                }
        },
        
        // 三级分销
        toThreeSell(){
                wx.navigateTo({//优惠买单
                        url: '/pages/Mydeploy/myThreeSell/myThreeSell',
                      }) 
        },

        // 其他功能
        toIntegral_trade(){//积分劵兑换积分
                wx.navigateTo({
                        url: '/pages/Mydeploy/myIntegral_trade/myIntegral_trade',
                      }) 
        },

        toGrow_trade(){//积分兑换成长值
                wx.navigateTo({
                        url: '/pages/Mydeploy/myGrow_trade/myGrow_trade',
                      }) 
        },

        toHelp_centre(){//帮助中心
                wx.navigateTo({
                        url: '/pages/Mydeploy/myHelp_centre/myHelp_centre',
                      }) 
        },

        toOneself_mes(){//个人信息
                wx.navigateTo({
                        url: '/pages/Mydeploy/myOneself_mes/myOneself_mes',
                      }) 
        },

        toSystem_set(){//系统设置
                wx.navigateTo({
                        url: '/pages/Mydeploy/mySystem_set/mySystem_set',
                      }) 
        },

        


        /**
         * 生命周期函数--监听页面初次渲染完成
         */
        onReady: function () {

        },

        /**
         * 生命周期函数--监听页面显示
         */
        onShow: function () {
                navigate("navigateBack",{url:"/pages/my/my?id=1"},true)

        },

        /**
         * 生命周期函数--监听页面隐藏
         */
        onHide: function () {

        },

        /**
         * 生命周期函数--监听页面卸载
         */
        onUnload: function () {

        },

        /**
         * 页面相关事件处理函数--监听用户下拉动作
         */
        onPullDownRefresh: function () {

        },

        /**
         * 页面上拉触底事件的处理函数
         */
        onReachBottom: function () {

        },

        /**
         * 用户点击右上角分享
         */
        onShareAppMessage: function () {

        }
})